//
//  LHTopTipsView.m
//  Loohoo
//
//  Created by 陈镇 on 2025/7/19.
//

#import "LHTopTipsView.h"

@interface LHTopTipsView ()

@property(nonatomic,strong) QMUILabel *tips;

@end
@implementation LHTopTipsView


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self addSubview:self.tips];
        self.backgroundColor = UIColorHex(#FFF2E6);
    }
    return self;
}

-(QMUILabel *)tips{
    if (!_tips) {
        _tips = [QMUILabel createTextColor:UIColorHex(#333333) font:SLFontMakeRegular(14) textAlignment:NSTextAlignmentLeft];
        _tips.numberOfLines = 0;
    }
    return _tips;
}


-(void)setText:(NSString *)text{
    _text = text;
    _tips.text = text;
    [self layoutIfNeeded];
    [self setNeedsLayout];
}

-(CGSize)sizeThatFits:(CGSize)size{
    
    CGSize tmp =  [_tips sizeThatFits:CGSizeMake(self.width - 20, CGFLOAT_MAX)];
    
    _tips.frame = CGRectMake(10, 10, self.width - 20, tmp.height);
    
    
    return CGSizeMake(self.width, tmp.height + 20);
}



@end
